function RenderMap (option) {
  this._init(option);
}
RenderMap.prototype = {
  _init: function (option) {
    this.series = this.set_series(option);
    this.tooltip = {
      show: true,
    }
    this.visualMap = {
      type: 'piecewise',
      pieces: [
        {min: 120, color: '#e74d53', label: 'x > 120'},
        {min: 80, max: 120, color: '#e39652', label: '80 < x ≤ 120'},
        {min: 50, max: 80, color: '#1c157e', label: '50 < x ≤ 80'},
        {min: 20, max: 50, color: '#053594', label: '20 < x ≤ 50'},
        {max: 20, color: '#19be6b', label: 'x ≤ 20'}
      ],
      itemWidth: 20,
      itemHeight: 10,
      itemSymbol: 'roundRect',
      backgroundColor: '#03276e',
      textStyle: {
        color: '#A6DFFE',
        fontFamily: 'Microsoft YaHei',
        fontSize: 12,
      },
      right: '30%',
      bottom: '15%'
    }
    this.geo = {
      show: true,
      map: `${option.map}`,
      zoom: 0.8,
      roam: true,
      // aspectScale: 1,
      // layoutCenter: ["50%", "50%"], //地图位置
      // layoutSize: '100%',
      itemStyle: {
        normal: {
          shadowColor: '#182f68',
          areaColor: '#182f68',
          shadowOffsetX: 5,
          shadowOffsetY: 5,
          opacity: 1,
        },
        emphasis: {
          areaColor: '#276fce',
        }
      },
    };
  },
  set_series: function(option) {
    return [
      {
        name: '网络时延',
        type: 'map',
        roam: true,
        zoom: 1,
        // map: option.map || '中国',
        label: {
          show: true,
          color: '#A6DFFE',
          fontSize: 10,
        },
        itemStyle: {
          areaColor: {
            type: 'radial',
            x: 0.5,
            y: 0.5,
            r: 1.5,
            colorStops: [{
                offset: 0, color: '#053594' // 0% 处的颜色
            }, {
                offset: 1, color: '#0f6ec9' // 100% 处的颜色
            }],
            global: false // 缺省为 false
          },
          // 区域边框颜色
          borderColor: '#03276e',
        },
        emphasis: {
          itemStyle: {
            areaColor: '#2AB8FF',
            borderWidth: 0,
          },
        },
        geoIndex: 0,
        data: option.data || []
      },
      {
        type: 'effectScatter',
        coordinateSystem: 'geo',
        showEffectOn: 'render',
        zlevel:1,
        rippleEffect: {
            period: 15,
            scale: 4,
            brushType: 'fill'
        },
        hoverAnimation: true,
        label: {
            normal: {
                formatter: '{b}',
                position: 'right',
                offset: [15, 0],
                color: '#1DE9B6',
                show: true
            },
        },
        itemStyle: {
            normal: {
               color:'#1DE9B6'/* function (value){ //随机颜色
return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);
}*/,
                shadowBlur: 10,
                shadowColor: '#333'
            }
        },
        symbolSize: 12,
        data: [
          {value: [104.48508, 30.303297]},
          {value: [104.040497,30.641922]}
        ]
    },
    {
      type: 'lines',
      zlevel: 2,
      effect: {
          show: false,
          period: 4, //箭头指向速度，值越小速度越快
          trailLength: 0.4, //特效尾迹长度[0,1]值越大，尾迹越长重
          symbol: 'arrow', //箭头图标
          symbolSize: 7, //图标大小
      },
      lineStyle: {
          normal: {
              color:'#1DE9B6',
              function (value){ //随机颜色

              ['#f21347','#f3243e','#f33736','#f34131','#f34e2b',
              '#f56321','#f56f1c','#f58414','#f58f0e','#f5a305',
              '#e7ab0b','#dfae10','#d5b314','#c1bb1f','#b9be23',
              '#a6c62c','#96cc34','#89d23b','#7ed741','#77d64c',
              '#71d162','#6bcc75','#65c78b','#5fc2a0','#5abead',
              '#52b9c7','#4fb6d2','#4ab2e5']
return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);
},
              width: 2, //线条宽度
              opacity: 1, //尾迹线条透明度
              curveness: .3 //尾迹线条曲直度
          }
      },
      data: [
          {coords: [[104.48508, 30.303297],[104.040497,30.641922]]},
          {coords: [[104.040497,30.641922],[104.48508, 30.303297]]}
      ]
  }
  ]
  }
}
export default RenderMap;
